package com.zzl.springboot_mybatis_demo.entity.common;

import lombok.Data;

/**
 * Description：通用实体类
 * Created by 朱正磊 on 2019-08-24 12:07
 */
@Data
public class CommonEntity {

    /**
     * 响应编码
     */
    public Integer code;

    /**
     * 提示信息
     */
    public String msg;

    /**
     * 业务数据
     */
    public Object data;

    private CommonEntity() {}

    private CommonEntity(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static CommonEntity build(Integer code, String msg, Object data) {
        return new CommonEntity(code, msg, data);
    }

    public static CommonEntity build(Integer code, String msg) {
        return new CommonEntity(code, msg, null);
    }

    public static CommonEntity build(String msg, Object data) {
        return new CommonEntity(null, msg, data);
    }

    public static CommonEntity build(Integer code, Object data) {
        return new CommonEntity(code, null, data);
    }

    public static CommonEntity build(Integer code) {
        return new CommonEntity(code, null, null);
    }

    public static CommonEntity build(String msg) {
        return new CommonEntity(null, msg, null);
    }

    public static CommonEntity build(Object data) {
        return new CommonEntity(null, null, data);
    }

}
